//
//  Monster.h
//  FruitCrush
//
//  Created by gaoyu on 15/7/9.
//
//

#ifndef __FruitCrush__Monster__
#define __FruitCrush__Monster__

#include "cocos2d.h"
#include "MonsterConfig.h"
USING_NS_CC;

typedef std::function<void(Ref*)> monsterBossAttackCallback;

class Monster : public cocos2d::Layer
{
public:
	CC_SYNTHESIZE(bool, m_isPause, IsPause);
    CC_SYNTHESIZE(int, m_swordProperty, SwordProperty);
    CC_SYNTHESIZE(int, m_arrowProperty, ArrowProperty);
    CC_SYNTHESIZE(int, m_fireProperty, FireProperty);
    CC_SYNTHESIZE(int, m_lightProperty, LightProperty);
    static Monster *create(int type);
    bool init(int type);
    virtual void update(float dt) override;
    Monster();
    bool changeHealth(int gap,int attackType,int doubleNum);
    void addHealth(int num);
    Size getSize();
    void setCallback(const monsterBossAttackCallback& callback);
    void destoryProtectCover();
protected:
    monsterBossAttackCallback _callback;
    
private:
    int hp;
    int maxHp;
    ProgressTimer *healthBar;
    bool m_isBoss;
    int m_nowHpLevel;
    Sprite *bossHpBarNext;
    float lastTime;
    bool m_isCover;
    void spriteInit(int type);
    void healthBarInit(int type);
    void showLostHp(int hp,int attackType,int doubleNum);
    void showAddHp(int hp);
    void showBeAttackAction();
    void propertyInit(int type);
    int getPropertyByAttackType(int attackType);
    int getHpChange(int gap,int attackType);
    bool checkZeroDamage(int damage);
    void bossHealthBarInit(int type);
    void healthBarChange();
    void gotoRightLevel();
    void changeHealthBarByLevel();
    void changeBossBarNext();
    void showBossAttackAction();
    void protectCoverInit();
    bool checkCoverModel();
    
};

#endif /* defined(__FruitCrush__Monster__) */
